package com.youchuang.action.admin;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.youchuang.action.BaseAction;
import com.youchuang.bean.Bulltion;
import com.youchuang.common.Constant;
import com.youchuang.service.AdminService;

/**
 * 公告发布
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/admin")
@ParentPackage("shopping-default")
public class BulltionInsertAction extends BaseAction {

	private Logger logger = Logger.getLogger(BulltionInsertAction.class.getSimpleName());
	
	@Resource
	private AdminService adminService;

	@Action(value = "bulltionInsert", results = {
			@Result(name = Constant.SUCCESS, type = "json", params = { "root", "resultObj" }) })
	public String execute() throws Exception {

		// TODO:处理重复提交的问题

		logger.info("method is execute");

		String name = request.getParameter(Constant.NAME);
		String content = request.getParameter(Constant.CONTENT);

		Bulltion bulltion = new Bulltion();
		bulltion.setName(name);
		bulltion.setContent(content);
		bulltion.setTime(System.currentTimeMillis());

		adminService.saveBulltion(bulltion);

		return Constant.SUCCESS;
	}

}
